



function setcookie (name, value, the_time) {
	var expDate = new Date();
	expDate.setTime (expDate.getTime() + (the_time * 1000));
	document.cookie = name + "=" + escape (value) + "; expires=" + expDate.toGMTString ();
}


function show_hidden_comm (id)
{
	document.getElementById('hidden_l'+id).style.display = 'none';
	document.getElementById('hidden_c'+id).style.display = 'block';
	return false;
}


function add_art_rating (the_id, the_value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.setVar("value", the_value);
		ajax.requestFile = "/include/ajax/articles/add_art_rating.php";
		ajax.method = "POST";
		ajax.element = "rating_" + the_id;
		ajax.sendAJAX(varsString);
}

function add_com_rating (the_id, the_value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.setVar("value", the_value);
		ajax.requestFile = "/include/ajax/comments_rating.php";
		ajax.method = "POST";
		ajax.element = "comm_rating_" + the_id;
		ajax.sendAJAX(varsString);
}





function add_answer (the_id, module, idi){
		var the_form = "<form name='answer' id='answer_form_" + the_id + "' action='' onsubmit=\"update_comments('" + module + "', " + the_id +", " + idi + "); return false;\" method=post><input type=hidden name=parent value='" + the_id + "'><textarea name=com_body rows=2 style='width:90%'></textarea>"+
			 "<br><input type=button value='скрыть' onclick='close_answer(" + the_id + ")'> <input type=submit value='добавить'></form>";
		var the_element = document.getElementById('answer_' + the_id);
		if (the_element.style.display == "none") {
			//the_element.style.display = "";
			the_element.innerHTML = the_form;
			$('#answer_'+the_id).slideDown('slow');
			document.answer.com_body.focus();
		}
		else {
			//the_element.style.display = "none";
			$('#answer_'+the_id).slideUp('slow');
			the_element.innerHTML = "";
		}
}
function update_comments (module, the_id, idi){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", idi);
		ajax.setVar("parent", the_id);
		ajax.setVar("module", module);
		ajax.setVar("com_body", document.getElementById("answer_form_" + the_id).com_body.value);
		ajax.requestFile = "/include/ajax/update_comments.php";
		ajax.method = "POST";
		ajax.element = "comments_div";
		ajax.sendAJAX(varsString);
}
function reload_captcha () {
	var rndval = new Date().getTime(); 
	document.getElementById('captcha_image').innerHTML = "<img src='/image.php?mod=bot&rnd=" + rndval + "' align='absmiddle' />";
}
function add_friend (the_id){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.requestFile = "/include/ajax/add_friend.php";
		ajax.method = "POST";
		ajax.element = "friends_list_false";
		ajax.sendAJAX(varsString);
}
function change_karma (the_id, value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("user_id", the_id);
		ajax.setVar("value", value);
		ajax.requestFile = "/include/ajax/karma.php";
		ajax.method = "POST";
		ajax.element = "karma_value";
		ajax.sendAJAX(varsString);
}
function vote_blog_karma (value, the_id){
		setcookie ("blog_" + the_id, "1", 36000);
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("blog_name", the_id);
		ajax.setVar("value", value);
		ajax.requestFile = "/include/ajax/articles/karma.php";
		ajax.method = "POST";
		ajax.element = "karma_value";
		ajax.sendAJAX(varsString);
}
function blog (the_id, type){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("blog_id", the_id);
		if (type == "join") ajax.setVar("type", "join");
		else ajax.setVar("type", "exit");
		ajax.requestFile = "/include/ajax/articles/blog.php";
		ajax.method = "POST";
		ajax.element = "blog_options";
		ajax.sendAJAX(varsString);
}


function show_reg_form () {
	document.getElementById('reg_form').style.display = "block";
	document.getElementById('screen').style.display = "block";
}

function close_reg_form () {
	document.getElementById('reg_form').style.display = "none";
	document.getElementById('screen').style.display = "none";
}

$(document).ready(function () {
/*	$("#logo").corner("10px tl tr");
	$("#menu").corner("10px bl br");
	$("#footer").corner("10px");
	$("#main_table").corner("10px");
	$("#user_karma").corner("10px");
	$(".block").corner("10px tl bl");
	//$(".blog_info").corner("10px");
	$(".site_message").corner("8px");
	$(".site_error").corner("8px");
	$("#second_navigation li").corner("8px tl tr");
	$("#second_navigation").corner("8px bl br");
	$("#block_last_user_arts").corner("10px");
	$("#block_users_top").corner("10px");*/	
});

function close_answer (the_id) {
	$('#answer_'+the_id).slideUp('slow');
}
